package com.jdcjk.project.car.model.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jdcjk.R;

import java.util.List;

/**
 * Created by Administrator on 2017/1/16 0016.
 */

public class CarWarningInfoAdapter extends BaseAdapter {
    private Context mContext;
    private List<String> warningInfoList;


    public CarWarningInfoAdapter(Context mContext, List<String> warningInfoList) {
        this.mContext = mContext;
        this.warningInfoList = warningInfoList;
    }


    @Override
    public int getCount() {
        return warningInfoList.size();
    }

    @Override
    public Object getItem(int position) {
        return warningInfoList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.item_warning_info, null);
            viewHolder.warningInfo_textview = (TextView) convertView.findViewById(R.id.warning_info_tv);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.warningInfo_textview.setText(warningInfoList.get(position));
        return convertView;
    }

    class ViewHolder {
        TextView warningInfo_textview;
    }
}
